package com.lcn.rabbitmq;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 测试发送消息的MQ配置
 */
//@Configuration
public class RabbitMQTestConfig {

    public static final String EXCHANGE_NAME = "test_exchange";

    public static final String QUEUE_NAME = "test_queue";

    public static final String ROUTING_KEY_TEST_SEND = "com.lcn.test";

//    @Bean(EXCHANGE_NAME)
    public Exchange exchange() {
        return ExchangeBuilder.topicExchange(EXCHANGE_NAME).durable(true).build();
    }

//    @Bean(QUEUE_NAME)
    public Queue queue() {
        return QueueBuilder.durable(QUEUE_NAME).build();
    }

//    @Bean
    public Binding binding(@Qualifier(EXCHANGE_NAME) Exchange exchange, @Qualifier(QUEUE_NAME) Queue queue) {
        return BindingBuilder.bind(queue).to(exchange).with("com.lcn.#").noargs();
    }

}
